#define _CRT_SECURE_NO_WARNINGS 1
#include"queue.h"

void InitXHQueue(XHQueue* q)
{
	assert(q);
	q->front = q->rear = 0;
	q->capacity = QMAX;
}

bool IsFull(XHQueue* q)
{
	return (q->rear + 1) % q->capacity == q->front;
}

void PushQNode(XHQueue* q,QDataType x)
{
	assert(q);
	assert(!IsFull(q));
	q->data[q->rear++] = x;
	q->rear %= q->capacity;
}

void PopQNode(XHQueue* q)
{
	assert(q);
	assert(!XHQueueEmpty(q));
	q->front++;
	q->front %= q->capacity;
}


QDataType XHQueueFront(XHQueue* q)
{
	assert(q);
	assert(!XHQueueEmpty(q));
	return q->data[q->front];
}

QDataType XHQueueRear(XHQueue* q)
{
	assert(q);
	assert(!XHQueueEmpty(q));
	return q->data[q->rear];
}
